//
//  LWBasicNvController.m
//  豆瓣
//
//  Created by 刘伟 on 16/7/6.
//  Copyright © 2016年 刘伟. All rights reserved.
//

#import "LWBasicNvController.h"
#import "UIBarButtonItem+Extension.h"
@interface LWBasicNvController ()

@end

@implementation LWBasicNvController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[UINavigationBar appearance] setTintColor:TheThemeColor];
 
}



-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.childViewControllers.count>0) {
        viewController.hidesBottomBarWhenPushed = YES;
        
        UIBarButtonItem *buttonItem = [UIBarButtonItem itemWithImage:@"nav_arrow" higlightedImage:@"nav_arrow" target:self action:@selector(superArrowButtonClick)];
        
        UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
        negativeSpacer.width = -20;
        self.navigationItem.leftBarButtonItems = @[negativeSpacer, buttonItem];
    }
    [super pushViewController:viewController animated:animated];


}
- (void)superArrowButtonClick{
    
    if ([self respondsToSelector:@selector(popViewControllerAnimated:)]){
        [self popViewControllerAnimated:YES];
    }
    if([self respondsToSelector:@selector(dismissModalViewControllerAnimated:)]){
        [self dismissViewControllerAnimated:YES completion:nil];
    }
}


@end
